import { reactive } from "vue";
import { getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";
import { getListApi } from "@/api/configCenter/outBoundAgent";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNum",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "代理账单号",
    keyName: "payableStatementNumber",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "代理商",
    keyName: "agentIdList",
    optionsRequest: getListApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  {
    type: "select",
    label: "账单类型",
    keyName: "statementType",
    optConfig: {
      label: "name",
      value: "code"
    },
    options: [
      {
        name: "代理对账单",
        code: 1
      },
      {
        name: "代理加收单",
        code: 2
      }
    ]
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  0: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "paymentBillNumber",
      title: "应付账单号",
      minWidth: "150"
    },
    {
      field: "payableStatementNumber",
      title: "代理账单号",
      minWidth: "150"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120",
      sortable: true
    },
    {
      field: "agent",
      title: "代理商",
      minWidth: "120",
      sortable: true
    },
    {
      field: "statementType",
      title: "账单类型",
      minWidth: "120",
      formatter: ({ cellValue }: any) => {
        if (cellValue === 1) return "代理对账单";
        else if (cellValue === 2) return "代理加收单";
        else return "-";
      },
      sortable: true
    },
    {
      field: "payableAmount",
      title: "导入应付金额",
      minWidth: "120"
    },
    {
      field: "surplusPayableAmount",
      title: "剩余应付金额",
      minWidth: "120"
    },
    {
      field: "shipmentCount",
      title: "运单数",
      minWidth: "100"
    },
    {
      field: "biller",
      title: "出账人",
      minWidth: "90"
    },
    {
      field: "billTime",
      title: "出账时间",
      minWidth: "135",
      formatter: "formatDate"
    }
  ],
  1: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "审批单号",
      minWidth: "150",
      renderSlot: "applyNo"
    },
    {
      field: "agent",
      title: "代理商",
      minWidth: "120",
      sortable: true
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120",
      sortable: true
    },
    {
      field: "paymentAmount",
      title: "请款金额",
      minWidth: "150"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "90"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "260",
      renderSlot: "action"
    }
  ],
  2: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "审批单号",
      minWidth: "150",
      renderSlot: "applyNo"
    },
    {
      field: "agent",
      title: "代理商",
      minWidth: "120",
      sortable: true
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120",
      sortable: true
    },
    {
      field: "paymentAmount",
      title: "请款金额",
      minWidth: "150"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "90"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "verificaStatus",
      title: "核销状态",
      minWidth: "90",
      renderSlot: "verificaStatus"

      // formatter: ({ cellValue }: any) => {
      //   if (cellValue === 1) return "未核销";
      //   else if (cellValue === 2) return "已核销";
      //   else return "-";
      // }
    },
    {
      field: "applyName",
      title: "通过人",
      minWidth: "90"
    },
    {
      field: "applyTime",
      title: "通过时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "100",
      renderSlot: "action"
    }
  ],
  3: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "审批单号",
      minWidth: "150",
      renderSlot: "applyNo"
    },
    {
      field: "agent",
      title: "代理商",
      minWidth: "120",
      sortable: true
    },
    {
      field: "paymentAmount",
      title: "请款金额",
      minWidth: "150"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "90"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "applyName",
      title: "驳回人",
      minWidth: "90"
    },
    {
      field: "applyTime",
      title: "驳回时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80",
      sortable: true
    },
    {
      field: "action",
      title: "操作",
      minWidth: "160",
      renderSlot: "action"
    }
  ]
};
// 统计
export const statisticsColumnMap: Base.GeneraDataType<Array<{ field: string; label: string }>> = {
  0: [
    {
      label: "账单数量",
      field: "statementCount"
    },
    {
      label: "剩余应付金额合计",
      field: "surplusPayableAmountSum"
    }
  ],
  1: [
    {
      label: "审批单数量",
      field: "applyCount"
    },
    {
      label: "请款金额",
      field: "paymentAmount"
    }
  ],
  2: [
    {
      label: "审批单数量",
      field: "applyCount"
    },
    {
      label: "请款金额",
      field: "paymentAmount"
    }
  ],
  3: [
    {
      label: "审批单数量",
      field: "applyCount"
    },
    {
      label: "请款金额",
      field: "paymentAmount"
    }
  ]
};
